﻿using MediatR;
using SmartProduction.Domain.Ptoduction;
using SmartProduction.ErrorCode;
using SmartProduction.Infarstructrue.Interface;
using SmartProduction.Read.API.Application.Commands.SCWorkCommand;

namespace SmartProduction.Read.API.Application.CommandHandlers.SCWorkCommandHandler
{
    public class SCWuPinQueryCommandHandler : IRequestHandler<SCWuPinQueryCommand, APIPaing<List<item_classification_detail>>>
    {
        private readonly IBaseRepository<item_classification_detail> iRepo;

        public SCWuPinQueryCommandHandler(IBaseRepository<item_classification_detail> iRepo)
        {
            this.iRepo = iRepo;
        }

        public async Task<APIPaing<List<item_classification_detail>>> Handle(SCWuPinQueryCommand request, CancellationToken cancellationToken)
        {
            try
            {
                APIPaing<List<item_classification_detail>> result = new APIPaing<List<item_classification_detail>>();
                var list = await iRepo.GetAll();
                result.data = list.ToList();
                result.Code = APIEnums.查询成功;
                result.Msg = APIEnums.查询成功.ToString();
                return await Task.FromResult(result);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
